﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MicroBenchmarks.UseDef
{
    /// <summary>
    /// A class where the desired method-call that helps to achieve desired state has a requirement
    /// that some other method needs to be invoked. This is called use-def relationship. 
    /// </summary>
    public class InternalFields1
    {
        private int member1, member2;
        private bool localState;
        public bool InternalState 
        {
            get {
                return localState;
            }
        }

        private void SetLocalState()
        {
            if (member1 == 5)
                localState = true;
        }

        public void IncrM1()
        {
            if(member2 != 100)
                throw new Exception("Member2 is not set properly");

            member1++;
            SetLocalState();
        }

        public void SetMember2()
        {
            this.member2 = 100;
        }
    }
}
